package com.xms.consumers.plugin;

import com.xms.core.enums.OperationStage;
import com.xms.plugin.core.IEntityPlugin;
import com.xms.plugin.core.PluginExecutionContext;
import com.xms.utils.MD5Util;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户默认密码插件
 * </p>
 *
 * @author migo
 * @since 2021/11/27
 */
@Service
public class SystemUserPasswordPlugin implements IEntityPlugin {

    public SystemUserPasswordPlugin() {

    }

    @Override
    public void execute(PluginExecutionContext context) throws Exception {
        if(context.stage == OperationStage.PreOperation){
            if(!context.target.containsKey("password")) {
                context.target.setValue("password", MD5Util.encode("123456"));
            }
        }
    }
}
